package com.tianqi.modules.pms.service.impl;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.read.listener.PageReadListener;
import com.nlf.calendar.EightChar;
import com.nlf.calendar.Lunar;
import com.nlf.calendar.Solar;
import com.tianqi.common.api.CommonResult;
import com.tianqi.common.enums.FulInitialsBeloEnum;
import com.tianqi.common.enums.GenderTypeEnum;
import com.tianqi.common.enums.RiGanDYGuiRenEnum;
import com.tianqi.common.enums.SanChuanEnum;
import com.tianqi.common.exception.ApiException;
import com.tianqi.common.service.impl.RedisServiceImpl;
import com.tianqi.common.utils.TimeUtils;
import com.tianqi.modules.pms.dto.request.DaLiuRenReqDTO;
import com.tianqi.modules.pms.dto.request.SanChuanFileReq;
import com.tianqi.modules.pms.dto.response.*;
import com.tianqi.modules.pms.service.DaLiuRenService;
import com.tianqi.modules.tqs.constant.RelationMapConstant;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * @className: DaLiuRenServiceImpl
 * @description: 大六壬实现类
 * @author: zp
 * @create: 2023-08-18 16:18
 **/
@Service
@Slf4j
public class DaLiuRenServiceImpl implements DaLiuRenService {
    @Autowired
    private TimeUtils timeUtils;
    @Value("${daliuren.filepath}")
    private String filePath;
    @Value("${daliuren.isProd}")
    private Boolean isProd;

    @Autowired
    private RedisServiceImpl redisServiceImpl;

    @Override
    public CommonResult<DaLiuRenRespDTO> getEightCharacters(DaLiuRenReqDTO daLiuRenReqDTO) {
        try{
            DaLiuRenRespDTO daLiuRenResp=new DaLiuRenRespDTO();
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date date = format.parse(daLiuRenReqDTO.getDivineTime());
            daLiuRenResp.setDateStr(format.format(date));
            // 计算真太阳时
            if (daLiuRenReqDTO.getTrueSolarTime() != null && daLiuRenReqDTO.getTrueSolarTime()) {
                if (StringUtils.isEmpty(daLiuRenReqDTO.getLocation())) {
                    throw new ApiException("计算真太阳时地点不能为空");
                }
                TimeConvertResultDTO timeConvertResultDTO = timeUtils.getTimeConvert(date,
                        daLiuRenReqDTO.getLocation());
                date = timeConvertResultDTO.getDate();
                daLiuRenReqDTO.setLatAndLon(timeConvertResultDTO.getLocation());
                daLiuRenReqDTO.setDateStr(format.format(date));
                daLiuRenResp.setDateStr(format.format(date));
            }
            //日期实例化
            Solar solar = Solar.fromDate(date);
            //时间转阴历
            Lunar lunar = solar.getLunar();
            //获取八字
            EightChar eightCharQuery=lunar.getEightChar();
            // 设置流派1
            eightCharQuery.setSect(1);
            //获取八字旬空
            daLiuRenResp.setYearInGanZhi(eightCharQuery.getYear());
            daLiuRenResp.setYearInXunKong(eightCharQuery.getYearXunKong());
            daLiuRenResp.setMonthInGanZhi(eightCharQuery.getMonth());
            daLiuRenResp.setMonthInXunKong(eightCharQuery.getMonthXunKong());
            daLiuRenResp.setDayInGanZhi(eightCharQuery.getDay());
            daLiuRenResp.setDayInXunKong(eightCharQuery.getDayXunKong());
            daLiuRenResp.setTimeInGanZhi(eightCharQuery.getTime());
            daLiuRenResp.setTimeInXunKong(eightCharQuery.getTimeXunKong());
            daLiuRenResp.setXunShou(RelationMapConstant.XUNSHOU_MAP.get(daLiuRenResp.getDayInGanZhi()));
            daLiuRenResp.setXunWei(RelationMapConstant.XUNWEI_MAP.get(daLiuRenResp.getDayInGanZhi()));
            //获取月将
            daLiuRenResp.setYueJiang(RelationMapConstant.YUEJIANGPAILIE_MAP.get(String.valueOf(lunar.getPrevJieQi(false))));
            //获取本命
            daLiuRenResp.setBenMing(daLiuRenReqDTO.getYearLife());
            //获取性别
            daLiuRenResp.setGenderType(GenderTypeEnum.getGenderByCode(daLiuRenReqDTO.getGenderType()).getInfo());
            String zhou="卯辰巳午未申";
            String ye="酉戌亥子丑寅";
            String guiZhi="";
            int zhouYeguiType=0;
            if(daLiuRenReqDTO.getStartMethod()==1 ||daLiuRenReqDTO.getStartMethod()==2){
                if(daLiuRenReqDTO.getZhouYeGui()==1){
                    guiZhi= RiGanDYGuiRenEnum.getValueByRiZhu(String.valueOf(daLiuRenReqDTO.getStartMethod()),daLiuRenResp.getDayInGanZhi().substring(0,1)).getZhouGui();
                    zhouYeguiType=1;
                }else if(daLiuRenReqDTO.getZhouYeGui()==2){
                    guiZhi= RiGanDYGuiRenEnum.getValueByRiZhu(String.valueOf(daLiuRenReqDTO.getStartMethod()),daLiuRenResp.getDayInGanZhi().substring(0,1)).getYeGui();
                    zhouYeguiType=2;
                }else{
                    if(zhou.indexOf(daLiuRenResp.getDayInGanZhi().substring(0,1))!=-1){
                        guiZhi=RiGanDYGuiRenEnum.getValueByRiZhu(String.valueOf(daLiuRenReqDTO.getStartMethod()),daLiuRenResp.getDayInGanZhi().substring(0,1)).getZhouGui();
                        zhouYeguiType=1;
                    }
                    if(ye.indexOf(daLiuRenResp.getDayInGanZhi().substring(0,1))!=-1){
                        guiZhi=RiGanDYGuiRenEnum.getValueByRiZhu(String.valueOf(daLiuRenReqDTO.getStartMethod()),daLiuRenResp.getDayInGanZhi().substring(0,1)).getZhouGui();
                        zhouYeguiType=2;
                    }
                }
            }else{
                return CommonResult.failed("请输入正确的贵人起法");
            }
            //获取天盘
            String[] diZhiShunXu = {"子",	"丑",	"寅",	"卯",	"辰",	"巳",	"午",	"未",	"申",	"酉",	"戌",	"亥"};

            int diPanStartNum=0;
            int tianPanStartNum=0;
            int guiRenStartNum=0;
            int xingNianStartNum=0;
            for(int i=0;i<diZhiShunXu.length;i++){
                if(diZhiShunXu[i].equals(daLiuRenResp.getTimeInGanZhi().substring(1))){
                    diPanStartNum=i;
                }
                if(diZhiShunXu[i].equals(daLiuRenResp.getYueJiang())){
                    tianPanStartNum=i;
                }
                if(diZhiShunXu[i].equals(daLiuRenResp.getBenMing())){
                    xingNianStartNum=i;
                }
            }
            //计算行年步数
            int xingNianBuShu=0;
            for(int c=0;c<diZhiShunXu.length;c++){
                if(xingNianStartNum==12){
                    xingNianStartNum=0;
                }
                if(diZhiShunXu[xingNianStartNum].equals(daLiuRenResp.getYearInGanZhi().substring(1))){
                    xingNianBuShu=xingNianBuShu+1;
                    break;
                }
                xingNianBuShu=xingNianBuShu+1;
                xingNianStartNum=xingNianStartNum+1;
            }
            if(daLiuRenReqDTO.getGenderType()==1){
                daLiuRenResp.setXingNian(diZhiShunXu[(1+xingNianBuShu)>11?(1+xingNianBuShu)-11:(1+xingNianBuShu)]);
            }else{
                daLiuRenResp.setXingNian(diZhiShunXu[(3-xingNianBuShu)<0?(3-xingNianBuShu)+11:(3-xingNianBuShu)]);
            }
            Map<String ,DaLiuRenTianPanDTO> tianPan=new HashMap<>();
            String guiRenDiZhi="";
            for(int j=0;j<12;j++){
                DaLiuRenTianPanDTO tianPanData=new DaLiuRenTianPanDTO();
                if(diPanStartNum==12){
                    diPanStartNum=0;
                }
                if(tianPanStartNum==12){
                    tianPanStartNum=0;
                }
                tianPanData.setDiPan(diZhiShunXu[diPanStartNum]);
                tianPanData.setTianPan(diZhiShunXu[tianPanStartNum]);
                if(diZhiShunXu[tianPanStartNum].equals(guiZhi)){
                    guiRenDiZhi=diZhiShunXu[diPanStartNum];
                }
                tianPan.put(tianPanData.getDiPan(),tianPanData);
                diPanStartNum=diPanStartNum+1;
                tianPanStartNum=tianPanStartNum+1;
            }
            List<String> guiRenDiZhiList=RelationMapConstant.SHOUFENGKONG_MAP.get(daLiuRenResp.getXunShou());
            for(int a=0;a<guiRenDiZhiList.size();a++){
                if(a==(guiRenDiZhiList.size()-1)){
                    tianPan.get(getDiZhi(guiRenDiZhiList.get(a).substring(0,1),tianPan)).setShouFengKongGan("");
                    tianPan.get(getDiZhi(guiRenDiZhiList.get(a).substring(1),tianPan)).setShouFengKongGan("");
                }else{
                    tianPan.get(getDiZhi(guiRenDiZhiList.get(a).substring(1),tianPan)).setShouFengKongGan(guiRenDiZhiList.get(a).substring(0,1));
                }

            }
            for(int i=0;i<diZhiShunXu.length;i++){
                if(diZhiShunXu[i].equals(guiRenDiZhi)){
                    guiRenStartNum=i;
                }
            }
            String shunDizhi="亥子丑寅卯辰";
            String niDizhi="巳午未申酉戌";
            String shunNiDizhi=getDiZhi(guiZhi,tianPan);
            //天盘贵人赋值
            for(int h=0;h<12;h++){
                if(guiRenStartNum==12){
                    guiRenStartNum=0;
                }
                if(zhouYeguiType==1&&shunDizhi.indexOf(shunNiDizhi)!=-1){
                    tianPan.get(diZhiShunXu[guiRenStartNum]).setQiGuiRen(RelationMapConstant.RIGANZHOUGUI_SHUNPAI_MAP.get(daLiuRenResp.getDayInGanZhi().substring(0,1)+tianPan.get(diZhiShunXu[guiRenStartNum]).getTianPan()));
                }
                if(zhouYeguiType==1&&niDizhi.indexOf(shunNiDizhi)!=-1){
                    tianPan.get(diZhiShunXu[guiRenStartNum]).setQiGuiRen(RelationMapConstant.RIGANZHOUGUI_NIPAI_MAP.get(daLiuRenResp.getDayInGanZhi().substring(0,1)+tianPan.get(diZhiShunXu[guiRenStartNum]).getTianPan()));
                }
                if(zhouYeguiType==2&&shunDizhi.indexOf(shunNiDizhi)!=-1){
                    tianPan.get(diZhiShunXu[guiRenStartNum]).setQiGuiRen(RelationMapConstant.RIGANYEGUI_SHUNPAI_MAP.get(daLiuRenResp.getDayInGanZhi().substring(0,1)+tianPan.get(diZhiShunXu[guiRenStartNum]).getTianPan()));
                }
                if(zhouYeguiType==2&&niDizhi.indexOf(shunNiDizhi)!=-1){
                    tianPan.get(diZhiShunXu[guiRenStartNum]).setQiGuiRen(RelationMapConstant.RIGANYEGUI_NIPAI_MAP.get(daLiuRenResp.getDayInGanZhi().substring(0,1)+tianPan.get(diZhiShunXu[guiRenStartNum]).getTianPan()));
                }
                tianPan.get(diZhiShunXu[guiRenStartNum]).setAbbreviation(FulInitialsBeloEnum.getValueByelEment("贵神",tianPan.get(diZhiShunXu[guiRenStartNum]).getQiGuiRen()).getAbbreviation());
                tianPan.get(diZhiShunXu[guiRenStartNum]).setFiveElementsColor(FulInitialsBeloEnum.getValueByelEment("贵神",tianPan.get(diZhiShunXu[guiRenStartNum]).getQiGuiRen()).getFiveElementsColor());
                tianPan.get(diZhiShunXu[guiRenStartNum]).setYinYangColor(FulInitialsBeloEnum.getValueByelEment("贵神",tianPan.get(diZhiShunXu[guiRenStartNum]).getQiGuiRen()).getYinYangColor());
                guiRenStartNum=guiRenStartNum+1;
            }
            daLiuRenResp.setTianpan(tianPan);
            //获取四课
            daLiuRenResp.setSike(getSiKe(daLiuRenResp.getDayInGanZhi(),daLiuRenResp.getTianpan()));
            //获取三传
            daLiuRenResp.setSanChuan(getSanCHuan(daLiuRenResp.getDayInGanZhi(),daLiuRenResp.getTianpan()));
            //获取神煞
            daLiuRenResp.setShenSha(getShenSha(daLiuRenResp));
            return CommonResult.success(daLiuRenResp);
        }catch(ParseException e){
            e.printStackTrace();
            return CommonResult.failed(e.getMessage());
        }catch(Exception e){
            e.printStackTrace();
            return CommonResult.failed(e.getMessage());
        }
    }
    private  Map<String , DaLiuRenSiKeDTO> getSiKe(String dayGanZhi,Map<String ,DaLiuRenTianPanDTO> tianPan){
        Map<String , DaLiuRenSiKeDTO> resultMap = new HashMap<>();
        DaLiuRenSiKeDTO sikeOne=new DaLiuRenSiKeDTO();
        sikeOne.setNum("一");
        sikeOne.setRiGan(dayGanZhi.substring(0,1));
        sikeOne.setDiZhi(RelationMapConstant.SHIGANJIGONG_MAP.get(sikeOne.getRiGan()));
        sikeOne.setKeZhi(tianPan.get(sikeOne.getDiZhi()).getTianPan());
        sikeOne.setShouFengKongGan("");
        sikeOne.setQiGuiRen(tianPan.get(getDiZhi(sikeOne.getKeZhi(),tianPan)).getQiGuiRen());
        sikeOne.setAbbreviation(tianPan.get(getDiZhi(sikeOne.getKeZhi(),tianPan)).getAbbreviation());
        sikeOne.setFiveElementsColor(tianPan.get(getDiZhi(sikeOne.getKeZhi(),tianPan)).getFiveElementsColor());
        sikeOne.setYinYangColor(tianPan.get(getDiZhi(sikeOne.getKeZhi(),tianPan)).getYinYangColor());
        DaLiuRenSiKeDTO sikeTwo=new DaLiuRenSiKeDTO();
        sikeTwo.setNum("二");
        sikeTwo.setRiGan(sikeOne.getKeZhi());
        sikeTwo.setKeZhi(tianPan.get(sikeTwo.getRiGan()).getTianPan());
        sikeTwo.setShouFengKongGan(tianPan.get(sikeTwo.getRiGan()).getShouFengKongGan());
        sikeTwo.setQiGuiRen(tianPan.get(getDiZhi(sikeTwo.getKeZhi(),tianPan)).getQiGuiRen());
        sikeTwo.setAbbreviation(tianPan.get(getDiZhi(sikeTwo.getKeZhi(),tianPan)).getAbbreviation());
        sikeTwo.setFiveElementsColor(tianPan.get(getDiZhi(sikeTwo.getKeZhi(),tianPan)).getFiveElementsColor());
        sikeTwo.setYinYangColor(tianPan.get(getDiZhi(sikeTwo.getKeZhi(),tianPan)).getYinYangColor());
        DaLiuRenSiKeDTO sikeThree=new DaLiuRenSiKeDTO();
        sikeThree.setNum("三");
        sikeThree.setRiGan(dayGanZhi.substring(0,1));
        sikeThree.setDiZhi(dayGanZhi.substring(1));
        sikeThree.setKeZhi(tianPan.get(sikeThree.getDiZhi()).getTianPan());
        sikeThree.setShouFengKongGan("");
        sikeThree.setQiGuiRen(tianPan.get(getDiZhi(sikeThree.getKeZhi(),tianPan)).getQiGuiRen());
        sikeThree.setAbbreviation(tianPan.get(getDiZhi(sikeThree.getKeZhi(),tianPan)).getAbbreviation());
        sikeThree.setFiveElementsColor(tianPan.get(getDiZhi(sikeThree.getKeZhi(),tianPan)).getFiveElementsColor());
        sikeThree.setYinYangColor(tianPan.get(getDiZhi(sikeThree.getKeZhi(),tianPan)).getYinYangColor());
        DaLiuRenSiKeDTO sikeFour=new DaLiuRenSiKeDTO();
        sikeFour.setNum("四");
        sikeFour.setRiGan(sikeThree.getKeZhi());
        sikeFour.setKeZhi(tianPan.get(sikeFour.getRiGan()).getTianPan());
        sikeFour.setShouFengKongGan(tianPan.get(sikeFour.getRiGan()).getShouFengKongGan());
        sikeFour.setQiGuiRen(tianPan.get(getDiZhi(sikeFour.getKeZhi(),tianPan)).getQiGuiRen());
        sikeFour.setAbbreviation(tianPan.get(getDiZhi(sikeFour.getKeZhi(),tianPan)).getAbbreviation());
        sikeFour.setFiveElementsColor(tianPan.get(getDiZhi(sikeFour.getKeZhi(),tianPan)).getFiveElementsColor());
        sikeFour.setYinYangColor(tianPan.get(getDiZhi(sikeFour.getKeZhi(),tianPan)).getYinYangColor());
        resultMap.put(sikeOne.getNum(),sikeOne);
        resultMap.put(sikeTwo.getNum(),sikeTwo);
        resultMap.put(sikeThree.getNum(),sikeThree);
        resultMap.put(sikeFour.getNum(),sikeFour);
        return resultMap;
    }
    private Map<String , DaLiuRenSanChuanDTO> getSanCHuan(String dayGanZhi, Map<String ,DaLiuRenTianPanDTO> tianPan){
        Map<String , DaLiuRenSanChuanDTO> resultMap = new HashMap<>();

        DaLiuRenSanChuanDTO sanChuanTwo=new DaLiuRenSanChuanDTO();
        sanChuanTwo.setChu(SanChuanEnum.getValueByRiZhu(dayGanZhi,tianPan.get("寅").getTianPan()).getChu());
        sanChuanTwo.setZhong(SanChuanEnum.getValueByRiZhu(dayGanZhi,tianPan.get("寅").getTianPan()).getZhong());
        sanChuanTwo.setMo(SanChuanEnum.getValueByRiZhu(dayGanZhi,tianPan.get("寅").getTianPan()).getMo());
        sanChuanTwo.setXu(SanChuanEnum.getValueByRiZhu(dayGanZhi,tianPan.get("寅").getTianPan()).getXu());
        sanChuanTwo.setKeGe(SanChuanEnum.getValueByRiZhu(dayGanZhi,tianPan.get("寅").getTianPan()).getKeGe());
        sanChuanTwo.setKeYi(SanChuanEnum.getValueByRiZhu(dayGanZhi,tianPan.get("寅").getTianPan()).getKeYi());
        sanChuanTwo.setJieYue(readSanChuanMsg().get(dayGanZhi+"_"+tianPan.get("寅").getTianPan()));
        DaLiuRenSanChuanDTO sanChuanOne=new DaLiuRenSanChuanDTO();
        sanChuanOne.setChu(tianPan.get(getDiZhi(sanChuanTwo.getChu(),tianPan)).getAbbreviation());
        sanChuanOne.setFiveElementsColorChu(tianPan.get(getDiZhi(sanChuanTwo.getChu(),tianPan)).getFiveElementsColor());
        sanChuanOne.setYinYangColorChu(tianPan.get(getDiZhi(sanChuanTwo.getChu(),tianPan)).getYinYangColor());
        sanChuanOne.setZhong(tianPan.get(getDiZhi(sanChuanTwo.getZhong(),tianPan)).getAbbreviation());
        sanChuanOne.setFiveElementsColorzhong(tianPan.get(getDiZhi(sanChuanTwo.getZhong(),tianPan)).getFiveElementsColor());
        sanChuanOne.setYinYangColorzhong(tianPan.get(getDiZhi(sanChuanTwo.getZhong(),tianPan)).getYinYangColor());
        sanChuanOne.setMo(tianPan.get(getDiZhi(sanChuanTwo.getMo(),tianPan)).getAbbreviation());
        sanChuanOne.setFiveElementsColormo(tianPan.get(getDiZhi(sanChuanTwo.getMo(),tianPan)).getFiveElementsColor());
        sanChuanOne.setYinYangColormo(tianPan.get(getDiZhi(sanChuanTwo.getMo(),tianPan)).getYinYangColor());
        DaLiuRenSanChuanDTO sanChuanThree=new DaLiuRenSanChuanDTO();
        sanChuanThree.setChu(tianPan.get(getDiZhi(sanChuanTwo.getChu(),tianPan)).getShouFengKongGan());
        sanChuanThree.setZhong(tianPan.get(getDiZhi(sanChuanTwo.getZhong(),tianPan)).getShouFengKongGan());
        sanChuanThree.setMo(tianPan.get(getDiZhi(sanChuanTwo.getMo(),tianPan)).getShouFengKongGan());
        DaLiuRenSanChuanDTO sanChuanFour=new DaLiuRenSanChuanDTO();
        sanChuanFour.setChu(FulInitialsBeloEnum.getValueByelEment("六亲",RelationMapConstant.TIANGAN_DIZHILIUQIN_MAP.get(dayGanZhi.substring(0,1)+sanChuanTwo.getChu())).getAbbreviation());
        sanChuanFour.setFiveElementsColorChu(FulInitialsBeloEnum.getValueByelEment("六亲",RelationMapConstant.TIANGAN_DIZHILIUQIN_MAP.get(dayGanZhi.substring(0,1)+sanChuanTwo.getChu())).getFiveElementsColor());
        sanChuanFour.setYinYangColorChu(FulInitialsBeloEnum.getValueByelEment("六亲",RelationMapConstant.TIANGAN_DIZHILIUQIN_MAP.get(dayGanZhi.substring(0,1)+sanChuanTwo.getChu())).getYinYangColor());
        sanChuanFour.setZhong(FulInitialsBeloEnum.getValueByelEment("六亲",RelationMapConstant.TIANGAN_DIZHILIUQIN_MAP.get(dayGanZhi.substring(0,1)+sanChuanTwo.getZhong())).getAbbreviation());
        sanChuanFour.setFiveElementsColorzhong(FulInitialsBeloEnum.getValueByelEment("六亲",RelationMapConstant.TIANGAN_DIZHILIUQIN_MAP.get(dayGanZhi.substring(0,1)+sanChuanTwo.getZhong())).getFiveElementsColor());
        sanChuanFour.setYinYangColorzhong(FulInitialsBeloEnum.getValueByelEment("六亲",RelationMapConstant.TIANGAN_DIZHILIUQIN_MAP.get(dayGanZhi.substring(0,1)+sanChuanTwo.getZhong())).getYinYangColor());
        sanChuanFour.setMo(FulInitialsBeloEnum.getValueByelEment("六亲",RelationMapConstant.TIANGAN_DIZHILIUQIN_MAP.get(dayGanZhi.substring(0,1)+sanChuanTwo.getMo())).getAbbreviation());
        sanChuanFour.setFiveElementsColormo(FulInitialsBeloEnum.getValueByelEment("六亲",RelationMapConstant.TIANGAN_DIZHILIUQIN_MAP.get(dayGanZhi.substring(0,1)+sanChuanTwo.getMo())).getFiveElementsColor());
        sanChuanFour.setYinYangColormo(FulInitialsBeloEnum.getValueByelEment("六亲",RelationMapConstant.TIANGAN_DIZHILIUQIN_MAP.get(dayGanZhi.substring(0,1)+sanChuanTwo.getMo())).getYinYangColor());
        resultMap.put("one",sanChuanOne);
        resultMap.put("two",sanChuanTwo);
        resultMap.put("three",sanChuanThree);
        resultMap.put("four",sanChuanFour);
        return resultMap;
    }
    private Map<String, String> readSanChuanMsg(){
        Map<String, String> mapData =(Map<String, String>)redisServiceImpl.get("DALIUREN_SANCHUAN");
        if(mapData!=null){
            return mapData;
        }
        Map<String, String> map=new HashMap<>();
        // 写法1：JDK8+ ,不用额外写一个DemoDataListener
        // since: 3.0.0-beta1
        String fileName = "/root/tianqi/excel/sanchuan.xlsx";
        if(isProd){
            fileName = filePath;
        }else{
            fileName=this.getClass().getClassLoader().getResource("excel/sanchuan.xlsx").getPath();
        }
        log.info(fileName);
        // 这里 需要指定读用哪个class去读，然后读取第一个sheet 文件流会自动关闭
        // 这里默认每次会读取100条数据 然后返回过来 直接调用使用数据就行
        // 具体需要返回多少行可以在`PageReadListener`的构造函数设置
        EasyExcel.read(fileName, SanChuanFileReq.class, new PageReadListener<SanChuanFileReq>(dataList -> {
            for (SanChuanFileReq demoData : dataList) {
                map.put(demoData.getKey(),demoData.getVal());
            }
        })).sheet().doRead();
        redisServiceImpl.set("DALIUREN_SANCHUAN",map);
        return map;
    }
    private String getDiZhi(String tianGan,Map<String ,DaLiuRenTianPanDTO> tianPan){
        Iterator<Map.Entry<String,DaLiuRenTianPanDTO>> iterable=tianPan.entrySet().iterator();
        String diZhi="";
        while(iterable.hasNext()){

            Map.Entry<String,DaLiuRenTianPanDTO>entry=iterable.next();
            if(entry.getValue().getTianPan().equals(tianGan)){
                diZhi=entry.getKey();
            }

        }
        return diZhi;
    }
    private Map<String,List<String>> getShenSha(DaLiuRenRespDTO daLiuRenResp){
        Map<String,List<String>> rewultShensha=new HashMap<>();
        //获取年支神煞
        List<String> nianZhiList= RelationMapConstant.SHENSHAFENLEI_MAP.get("NIANZHI_DALIUREN");
        List<String> nianZhiShensha=new ArrayList<>();
        nianZhiList.forEach((e)->{
            nianZhiShensha.add(e+"："+RelationMapConstant.NIANZHISHENSHA_MAP.get("大六壬_"+daLiuRenResp.getYearInGanZhi().substring(1)+"_"+e));

        });
        rewultShensha.put("nianZhiShensha",nianZhiShensha);
        //获取年干神煞
        List<String> nianGanList= RelationMapConstant.SHENSHAFENLEI_MAP.get("NIANGAN_DALIUREN");
        List<String> nianGanShensha=new ArrayList<>();
        nianGanList.forEach((e)->{
            nianGanShensha.add(e+"："+RelationMapConstant.NIANGANSHENSHA_MAP.get("大六壬_"+daLiuRenResp.getYearInGanZhi().substring(0,1)+"_"+e));
        });
        rewultShensha.put("nianGanShensha",nianGanShensha);
        //月支月神煞
        List<String> yueZhiYueList= RelationMapConstant.SHENSHAFENLEI_MAP.get("YUEZHI_DALIUREN_YUE");
        List<String> yueZhiYueShensha=new ArrayList<>();
        yueZhiYueList.forEach((e)->{
            yueZhiYueShensha.add(e+"："+RelationMapConstant.YUEZHISHENSHA_MAP.get("大六壬_"+daLiuRenResp.getMonthInGanZhi().substring(1)+"_"+e));
        });
        rewultShensha.put("yueZhiYueShensha",yueZhiYueShensha);
        //月支季神煞
        List<String> yueZhiJiList= RelationMapConstant.SHENSHAFENLEI_MAP.get("YUEZHI_DALIUREN_JI");
        List<String> yueZhiJiShensha=new ArrayList<>();
        yueZhiJiList.forEach((e)->{
            yueZhiJiShensha.add(e+"："+RelationMapConstant.YUEZHISHENSHA_MAP.get("大六壬_"+daLiuRenResp.getMonthInGanZhi().substring(1)+"_"+e));
        });
        rewultShensha.put("yueZhiJiShensha",yueZhiJiShensha);
        //日干神煞
        List<String> riGanList= RelationMapConstant.SHENSHAFENLEI_MAP.get("RIGAN_DALIUREN");
        List<String> riGanShensha=new ArrayList<>();
        riGanList.forEach((e)->{
            riGanShensha.add(e+"："+RelationMapConstant.RIGANSHENSHA_MAP.get("大六壬_"+daLiuRenResp.getDayInGanZhi().substring(0,1)+"_"+e));
        });
        rewultShensha.put("riGanShensha",riGanShensha);
        //日支神煞
        List<String> riZhiList= RelationMapConstant.SHENSHAFENLEI_MAP.get("RIZHI_DALIUREN");
        List<String> riZhiShensha=new ArrayList<>();
        riZhiList.forEach((e)->{
            riZhiShensha.add(e+"："+RelationMapConstant.RIZHISHENSHA_MAP.get("大六壬_"+daLiuRenResp.getDayInGanZhi().substring(1)+"_"+e));
        });
        rewultShensha.put("riZhiShensha",riZhiShensha);
        return rewultShensha;
    }
}
